<?php
class editAction extends rareAction{
	public function execute(){
		$id = $this->getGetParam('id',0);
		if($id == 0) forward('banner/index');
		$dao = new DaoImage();
		$image = $dao->getOne("id='$id'");
		$type = $this->getGetParam('type',0);
		$this->assign('type',$type);
		$this->assign('image',$image);
		if(!Tool::_getCache('isAdmin')&&in_array($type,array(service_type::BANNER,service_type::SLIDE))){
			Tool::_setCache('currentID',service_menu::getCurrent('1',$type));
		}
	}
	public function executePost(){
		$banner = $this->getPostParam('banner',array());
		$id = $this->getPostParam('id',0);
		$images = $this->getPostParam('img',array());
		if(empty($banner) || $id==0) jsonReturn(0,'参数错误');
		if(!empty($images)){
			$banner['src'] = $images[0];
		}
		$dao = new DaoImage();
		
		$dao->update(" id = '$id'",$banner);
		jsonReturn(1,'ok');
	}
}
?>
